package com.education.welco.controller;

import com.education.auth.aspectannotation.BusinessDiary;
import com.education.common.core.BaseController;
import com.education.common.utils.ApiReturnObject;
import com.education.welco.pojo.LLabel;
import com.education.welco.service.ILLabelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

/**
 * 标签字典 信息操作处理
 *
 * @author d
 * @date 2020-05-08
 */
@RestController
@RequestMapping("/lLabel")
public class LLabelController extends BaseController {

    @Autowired
    private ILLabelService labelService;

    /**
     *  查找标签列表
     */
    @GetMapping("/list")
    @BusinessDiary(methodUrl = "/accredit",record = "智慧云课堂管理端用户登录",opeTypeName = "登录999")
    private ApiReturnObject list(LLabel label){
        //查询平台课程标签
        List<LLabel> lLabels = labelService.selectLLabelList(label);
        return new ApiReturnObject("200","查询成功",lLabels);
    }

    /**
     *  添加标签
     */
    @PostMapping("/add")
    public ApiReturnObject add(@RequestBody LLabel label){
        label.setCreateTime(new Date());
        labelService.insertLLabel(label);
        return new ApiReturnObject("200","添加成功","");
    }

    /**
     *  刪除
     */
    @PostMapping("/del")
    public ApiReturnObject del(@RequestBody LLabel label ){
        if(label.getId() != null){
            labelService.deleteLLabelById(label.getId());
            return new ApiReturnObject("200","删除成功","");
        }
        return new ApiReturnObject("201","缺少参数","");
    }


}